#!/usr/bin/python
import sys
import os

def main():
    if len(sys.argv) < 3:
        usage()
        return

    for i in range(2, len(sys.argv)):
        get_files(sys.argv[1], sys.argv[i])

def get_files(rule, file):
    if os.path.isdir(file):
        return
    (name, ext) = os.path.splitext(file)
    os.rename(file, name + rule)

def usage():
    print 'example: batchrenamef .cpp file.txt'
    print 'result : file.txt become file.cpp'

if __name__ == '__main__':
    main()
